package br.fatec.ads.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import br.fatec.ads.dao.RespostaDAO;
import br.fatec.ads.exception.DataBaseException;
import br.fatec.ads.exception.RespostaException;
import br.fatec.ads.model.Resposta;

public class RespostaConsultar extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public RespostaConsultar() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			HttpSession session = request.getSession(false);
			
			Resposta resposta = new Resposta();
			RespostaDAO respostaDAO = new RespostaDAO();
		
			resposta = respostaDAO.getResposta(Integer.parseInt(request.getParameter("idRespostaConsultar")));
			
			 session.setAttribute("resposta", resposta);
			 
			 request.getRequestDispatcher("cadresposta_c.jsp").forward(request, response);
		} catch (RespostaException e) {
			e.printStackTrace();
		} catch (DataBaseException e) {
			e.printStackTrace();
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}
}